package system;

import java.rmi.Remote;
import java.rmi.RemoteException;

/**
 * Interface to be implemented by the Worker. This interface
 * will be used by the Master to communicate with a Worker  
 * 
 * @author Mayuri Karra, Bing Wei
 *
 */

public interface Worker extends Remote{
	
	/**
	 * The method to execute a given task passed by the Master.
	 * The task can be map/reduce
	 * 
	 * @param masterTask
	 * @return the time taken by this task to execute
	 * @throws RemoteException
	 */
	public long execute(MasterTaskBase masterTask) throws RemoteException;

	/**
	 * Getter method for worker id
	 * @return the id of worker thread.
	 * @throws RemoteException
	 */
	public int getWorkerId() throws RemoteException;
	
	/**
	 * method for pinging a worker.
	 * @throws RemoteException
	 */
	void getPing() throws RemoteException;
	
	/**
	 * Method to lookup a given key in the output of reduce phase.
	 * Invoked by Master when a client asks the Master for the key
	 * @param masterTask
	 * @return the result as a String
	 * @throws RemoteException
	 */
	public String lookup(MasterTaskBase masterTask) throws RemoteException;
}
